package com.coco.controller;

import com.coco.dao.OrderMapper;
import com.coco.entity.Order;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

@RestController
public class OrderController {


    @Autowired
    private OrderMapper orderMapper;

    @RequestMapping("/test")
    @Transactional
    public void test() {
        Order order = new Order();
        order.setId(4L);
        order.setUserId(20);
        order.setOrderAmount(BigDecimal.TEN);
        order.setOrderStatus(1);
        orderMapper.saveData(order);

        Order order1 = new Order();
        order1.setId(4L);
        order1.setUserId(21);
        order1.setOrderAmount(BigDecimal.TEN);
        order1.setOrderStatus(1);
        orderMapper.saveData(order1);
        throw new RuntimeException("123");
    }

}
